/**
 * Project Name:pay-demo
 * File Name:SignatureUtil.java
 * Package Name:com.pay.util
 * Date:2018年7月4日下午4:22:05
 * Copyright (c) 2018, www.zengfull.com All Rights Reserved.
 *
*/

package com.rc.saas.payment.unwxpay.util;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.TreeMap;

public class SignatureUtil {
    public static String getSignatureStr(Map<String, String> respMap) {
        Map<String, String> map = new TreeMap<String, String>();
        map.putAll(respMap);
        StringBuffer signature = new StringBuffer();
        for (String key : map.keySet()) {
            if (!StringUtils.isEmpty(map.get(key)) && !"signature".equals(key)) {
                signature.append(key + "=" + map.get(key) + "&");
            }
        }
        return signature.toString().substring(0, signature.length() - 1);
    }
}

